package model.trader.trade;
//AMLOW: behavioural.. with multiple assets this needs to get called in a different way.
//package model.trader.strategy;
//
//import model.market.MarketManager;
//import model.market.Position;
//import model.market.Trade;
//import model.trader.Trader;
//
//public class BehaviouralTraderPatterns {
//
//	/*
//	 * Like they say - Quit while you're ahead! hang on if you're losing, otherwise do nothing.
//	 * @return true if position should be closed, false if should not trade, null if prospect theory dont care.
//	 */
//	public Boolean prospectTheoryTradeRecomendation(Trader trader,
//														Position position,
//														MarketManager market,
//														double gainTolerance,
//														double lossTolerance){
//		int positionQuantity = position.getExecutedQuantity();
//		if(positionQuantity!=0){
//			//determine by the last trade made what we should do..
//			Trade latest = position.getExecutedTrades().get(position.getExecutedTrades().size()-1);
//			
//			
//			if((positionQuantity<0&&
//					latest.getExecutedPrice()>(market.getMarketPrice()*(1+gainTolerance))&&
//						latest.getDirection()==Trade.SELL)
//						||
//			   (positionQuantity>0&&
//					   latest.getExecutedPrice()*(1+gainTolerance)<market.getMarketPrice()&&
//			   			latest.getDirection()==Trade.BUY)){
//				//Cash out!!
//				return new Boolean(true);
//			}
//			
//			if((positionQuantity<0&&
//					latest.getExecutedPrice()*(1+lossTolerance)<(market.getMarketPrice())&&
//						latest.getDirection()==Trade.SELL)
//						||
//			   (positionQuantity>0&&
//					   latest.getExecutedPrice()>market.getMarketPrice()*(1+lossTolerance)&&
//			   			latest.getDirection()==Trade.BUY)){
//				//Hang on!!
//				return new Boolean(false);
//			}
//			
//		}
//		return null;
//	}
//}
